Profile Routines and Example - by Dave Mosier - 12/15/92 These Visual Basic routines make using the Windows Profile API a little easier and safer. The routines have been tested but may not be fully debugged. You may feel free to use them in any way you see fit. The only requirement is that when these routines and the example program are stored on a BBS, this file always be kept with them. File List: PROFILE.EXE - The complied version of the example program FORM1.FRM - The main window of the example FORM2.FRM - The Write-String prompt window for the example GLOBAL.BAS - The Global declarations for the example (very small) PROJECT1.MAK - The make file for the example PROFILE.BAS - The profile routines PROFILE.TXT - This file Profile Functions: I tried to transfer to profile fuctions from there respective C declarations as purely as possible. However, I could not resist makin two changes that seem to make the parameters easier to understand. One, the name lpAppName is changed to TOPIC. And two, the parameter lpKeyName is changed to ITEM. In retrospect, KEYNAME would probably have been better than ITEM, but that's life. The folowing Windows API's are used. WriteProfileString GetProfileInt GetProfileString GetPrivateProfileInt GetPrivateProfileString WritePrivateProfileString The folowing profile routines were created. GetPrivateString (Topic As String, Item As String, RetStr As String) GetPrivateList (Topic1 As String, List() As String) GetPrivateInt (Topic As String, Item As String, ValueInt As Integer) WritePrivateString (Topic As String, Item As String, WriteStr As String) DelItemPrivate (Topic As String, Item As String) DelTopicPrivate (Topic As String) GetWinString (Topic As String, Item As String, RetStr As String) GetWinList (Topic1 As String, List() As String) GetWinInt (Topic As String, Item As String, ValueInt As Integer) WriteWinString (Topic As String, Item As String, WriteStr As String) DelItemWin (Topic As String, Item As String) DelTopicWin (Topic As String) Example Program: The example program shows how the private profile routines work. The WIN version of the routines work virtually the same. I did not include the WIN routines in the example to ensure that the example program did not mess up anyone's WIN.INI file. PROFILE.EXE starts by creating a profile file called PTEST.INI. If by some chance you already have a PTEST.INI file, the PROFILE.EXE will over write it (so save your original before running PROFILE.EXE). The program next displays it's main window and show the current contents of PTEST.INI. The command buttons allow you to see how the various functions work. The error codes are a combination of the codes returned by Windows and some extra error checking that the routines perform. As a note, the only time I have gotten the Write-String functions to fail is if the PTEST.INI file was write protected after it was created. Otherwise, the Write-String functions just plug right along. I could not come up with a good way to find out what [Topics] were in an INI file so I had to resort to brute force, scanning for the "[" and "]" character. If anyone knows a better way, I would appreciate hearing from you. If you have any questions or comments, Dave Mosier can be reached at 71064,3436